/*
 *  Copyright (C) 2005-2007 Renier Roth
 *  www.renier.de
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package de.renier.jkeepass.elements;

import de.renier.jkeepass.util.IconPool;


/**
 * ContainerElement
 *
 * @author <a href="mailto:software@renier.de">Renier Roth</a>
 */
public class ContainerElement implements Element {
  
  private static final long serialVersionUID = -6706633240614023925L;
  private String name;
  private String symbol;
  private BasicElementList elements;
  
  /**
   * Constructor for ContainerElement
   *
   * @param name
   */
  public ContainerElement(String name, String symbol) {
    this.name = name;
    this.symbol = symbol;
  }

  /* (non-Javadoc)
   * @see de.renier.jkeepass.elements.Element#getName()
   */
  public String getName() {
    return this.name;
  }
  
  /*
   * (non-Javadoc)
   * @see de.renier.jkeepass.elements.Element#getSymbol()
   */
  public String getSymbol() {
    if (this.symbol == null) return IconPool.DEFAULT_CONTAINER_ID;
    return this.symbol;
  }

  /**
   * setName
   *
   * @param name The name to set.
   */
  public void setName(String name) {
    this.name = name;
  }

  /**
   * setSymbol
   *
   * @param symbol The symbol to set.
   */
  public void setSymbol(String symbol) {
    this.symbol = symbol;
  }

  /**
   * getElements
   *
   * @return Returns the elements.
   */
  public BasicElementList getElements() {
    return elements;
  }

  /**
   * setElements
   *
   * @param elements The elements to set.
   */
  public void setElements(BasicElementList elements) {
    this.elements = elements;
  }
  
  /**
   * addBasicElement
   *
   * @param element
   */
  public void addBasicElement(BasicElement element) {
    if (elements == null) elements = new BasicElementList();
    elements.add(element);
  }

  /* (non-Javadoc)
   * @see java.lang.Object#toString()
   */
  public String toString() {
    return this.getClass().getName() + "[name=" + name + "]";
  }
  
  
}
